/**
 * Created by Administrator on 15-7-16.
 */
var Core = RichBase.extend({
	statics : {},
	api : "call/jh_prod.php",
	/**
	 *
	 * @param lid
	 * @param salerid
	 * @param title
	 * @param state state=1 => 查询已合并的    state=2 => 查询
	 * @param opt
	 * @returns {boolean}
	 */
	queryLand : function(lid,salerid,title,state,opt){
		if(!lid || !salerid) return false;
		var title = title || "";
		var api = this.api;
		var fn = function(){};
		var opt = opt || {};
		var loading = opt.loading || fn;
		var removeLoading = opt.removeLoading || fn;
		var success = opt.success || fn;
		var timeout = opt.timeout || fn;
		var fail = opt.fail || fn;
		var serverError = opt.serverError || fn;
		PFT.Ajax({
			url : api,
			type : "get",
			dataType : "json",
			ttimeout : 20 * 10000,
			data : {
				state : state,
				lid : lid,
				salerid : salerid,
				action : "terminal_merge_search",
				ltitle : title
			},
			loading : function(){ loading()},
			removeLoading : function(){ removeLoading()},
			timeout : function(){ timeout()},
			serverError : function(){ serverError()}
		},function(res){
			var status = res.status;
			if(status=="ok"){
				success(res);
			}else{
				fail(res);
			}
		})
	},
	/**
	 * 合并
	 * @param opt
	 * main_id : 主id
	 * merge_id : 数组
	 */
	merge : function(opt){
		var opt = opt || {};
		var main_id = opt.main_id;
		var merge_id = opt.merge_id;
		var api = this.api;
		var fn = function(){};
		var loading = opt.loading || fn;
		var removeLoading = opt.removeLoading || fn;
		var success = opt.success || fn;
		var timeout = opt.timeout || fn;
		var fail = opt.fail || fn;
		var serverError = opt.serverError || fn;
		PFT.Ajax({
			url : api,
			type : "post",
			dataType : "json",
			ttimeout : 20 * 10000,
			data : {
				main_id : main_id,
				merge_id : merge_id,
				action : "terminal_merge"
			},
			loading : function(){ loading()},
			removeLoading : function(){ removeLoading()},
			timeout : function(){ timeout()},
			serverError : function(){ serverError()}
		},function(res){
			var status = res.status;
			if(status=="ok"){
				success(res);
			}else{
				fail(res);
			}
		})
	}
});